package com.woniu.controller;


import com.woniu.entity.Menu;
import com.woniu.service.MenuService;
import com.woniu.util.ResponseData;
import com.woniu.util.UserContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {

    @Resource
    private MenuService menuService;


    /**
    * 用来查询菜单的
    * */
    @GetMapping("/queryMenu")
    public ResponseData<?> queryMenus() throws ParseException {
        Long contextEmpId = UserContext.getContextEmpId();          // 获取登录人的id
        int employeeId = Integer.parseInt(String.valueOf(contextEmpId));

        List<Menu> menus = menuService.queryMenus(employeeId);
        return ResponseData.ok(menus);

    }
}
